﻿<%@ Page Language="C#" MasterPageFile="~/Base.Master" AutoEventWireup="true" CodeBehind="Taxes.aspx.cs" Inherits="SVAccountingWebUI.Taxes" %>
<%@ MasterType VirtualPath="~/Base.Master" %>

<asp:Content ID="TaxesContent" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="TaxCode" 
        DataSourceID="TaxesLinqDataSource"
        onrowcancelingedit="gv_RowCancelingEdit" 
        onrowdeleting="gv_RowDeleting" onrowediting="gv_RowEditing"
        >
        <Columns>
            <asp:TemplateField  HeaderText="<%$ Resources:Resource, EditDelete %>">
                <EditItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" ImageUrl="~/Icons/Update.png" Text="Update" />
                    &nbsp;<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" ImageUrl="~/Icons/Cancel.png" Text="Cancel" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" ImageUrl="~/Icons/Edit.png" Text="Edit" />
                    &nbsp;<asp:ImageButton ID="DeleteButton" runat="server" CausesValidation="False" 
                        CommandName="Delete" ImageUrl="~/Icons/delete.png" Text="Delete"
                        message="<%$ Resources:Resource, DeleteConfirm %>" 
                        OnClientClick='return confirm(this.getAttribute("message"))'
                        />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="TaxCode" HeaderText="<%$ Resources:Resource, TaxCode %>" ReadOnly="True" 
                SortExpression="TaxCode" />
            <asp:BoundField DataField="TaxName" HeaderText="<%$ Resources:Resource, TaxName %>" 
                SortExpression="TaxName" />
            <asp:BoundField DataField="Value" HeaderText="<%$ Resources:Resource, Value %>" SortExpression="Value" />
            <asp:BoundField DataField="PrecedingValue" HeaderText="<%$ Resources:Resource, PrecedingValue %>" 
                SortExpression="PrecedingValue" />
        </Columns>
    </asp:GridView>
    
    <asp:LinqDataSource ID="TaxesLinqDataSource" runat="server" 
        ContextTypeName="SVAccountingBL.SVALinqDataContext" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" TableName="Taxes"
        ondeleted="LinqDataSource_Deleted" 
        onupdated="LinqDataSource_Updated" 
        oninserted="LinqDataSource_Inserted" 
        >
    </asp:LinqDataSource>
    
    
   <asp:UpdatePanel ID="AddNewPanel" runat="server">
   <ContentTemplate>
    <br />
    <asp:LinkButton ID="lbtnAddNew" runat="server" 
                    Text="<%$ Resources:Resource, AddNew %>" 
           onclick="AddNew_Click"/>
    <br />
    <br />
   <div ID="InsertDiv" runat="server" visible="false">
       
       
       
       <asp:DetailsView ID="dvInsert" runat="server" AutoGenerateRows="False" 
           DataKeyNames="TaxCode" DataSourceID="TaxesLinqDataSource" DefaultMode="Insert" 
           Height="50px" Width="125px" onitemcommand="InsertDV_ItemCommand">
           <Fields>
               <asp:BoundField DataField="TaxCode" HeaderText="<%$ Resources:Resource, TaxCode %>" ReadOnly="True" 
                   SortExpression="TaxCode" InsertVisible="false" />
               <asp:TemplateField HeaderText="<%$ Resources:Resource, TaxName %>" SortExpression="TaxName">
                   <EditItemTemplate>
                       <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TaxName") %>'></asp:TextBox>
                   </EditItemTemplate>
                   <InsertItemTemplate>
                   <table>
                    <tr>
                    <td>
                       <asp:TextBox ID="txtTaxName" runat="server" Text='<%# Bind("TaxName") %>'></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ID="rfvTaxName" runat="server" ErrorMessage="*" ControlToValidate="txtTaxName" EnableClientScript="true" />
                    </td>
                    </tr>
                   </table>
                    
                   </InsertItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label1" runat="server" Text='<%# Bind("TaxName") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:TemplateField  HeaderText="<%$ Resources:Resource, Value %>" SortExpression="Value">
                   <EditItemTemplate>
                       <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Value") %>'></asp:TextBox>
                   </EditItemTemplate>
                   <InsertItemTemplate>
                   <table>
                    <tr>
                    <td>
                       <asp:TextBox ID="txtValue" runat="server" Text='<%# Bind("Value") %>'></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ID="rfvTaxValue" runat="server" ErrorMessage="*" ControlToValidate="txtValue" EnableClientScript="true" />
                    </td>
                    </tr>
                   </table>
                       
                   </InsertItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label2" runat="server" Text='<%# Bind("Value") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:TemplateField HeaderText="<%$ Resources:Resource, PrecedingValue %>" SortExpression="PrecedingValue">
                   <EditItemTemplate>
                       <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("PrecedingValue") %>'></asp:TextBox>
                   </EditItemTemplate>
                   <InsertItemTemplate>
                    <table>
                    <tr>
                    <td>
                       <asp:TextBox ID="txtPrecedingValue" runat="server" Text='<%# Bind("PrecedingValue") %>'></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ID="rfvPrecedingValue" runat="server" ErrorMessage="*" ControlToValidate="txtPrecedingValue" EnableClientScript="true" />
                    </td>
                    </tr>
                   </table>
                       
                   </InsertItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label3" runat="server" Text='<%# Bind("PrecedingValue") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:CommandField ButtonType="Image" CancelImageUrl="~/Icons/Cancel.png" 
                   InsertImageUrl="~/Icons/Add.png" ShowInsertButton="True" />
           </Fields>
       </asp:DetailsView>
       
       
       
    </div>
    </ContentTemplate>
    
    <Triggers>
         <asp:AsyncPostBackTrigger ControlID="lbtnAddNew" EventName="click" />
         <asp:PostBackTrigger ControlID="dvInsert" /> 
    </Triggers>
    
   </asp:UpdatePanel>




</asp:Content>